
def records = new XmlSlurper().parseText(XmlExamples.CAR_RECORDS)

def sortedNames = records.car.list().sort{ it.@year.toInteger() }

def stringWriter = new StringWriter()

for(car in sortedNames) {
    print groovy.xml.XmlUtil.serialize(car)
}

